home *** CD-ROM | disk | FTP | other *** search
/ Aminet 31 / Aminet 31 (1999)(Schatztruhe)[!][Jun 1999].iso / Aminet / dev / gui / gui4cli.lha / Gui4Cli / Tools / FileReq.gc < prev    next >
Text File  |  1999-04-21  |  7KB  |  322 lines

  1. G4C
  2.  
  3. ; FILEREQ.GC
  4. ; A multiselect File Requester with Favourites etc..
  5.  
  6. ; GuiLoad guis:tools/filereq.gc  GuiName Routine Path FavFile  -or
  7. ; GuiOpen filereq.gc  GuiName Routine Path FavFile
  8.  
  9. ; GuiName  - Name of your gui
  10. ; Routine  - Routine in your gui that will be called
  11. ; Path     - (optional) path to open at - if you want..
  12. ; FavFile  - (optional) name of the Favourites file
  13.  
  14. ; ====================================================================
  15.  
  16. ;               Globals
  17.  
  18. ; ====================================================================
  19.  
  20. WINBIG 185 16 291 213 'Choose file(s) :'
  21. WinType 11110001
  22. varpath ''
  23.  
  24. BOX 0 0 291 213 in icondrop
  25.  
  26.  
  27. ; ====================================================================
  28.  
  29. ;               System events
  30.  
  31. ; ====================================================================
  32.  
  33. xONLOAD  gui routine path favfile 
  34.    if  $gui > ''           ; dont pass them if you just want to load it.
  35.    and $routine > ''
  36.        guiopen filereq.gc $gui $routine $path $favfile
  37.    endif
  38.  
  39. xONRELOAD  gui routine path favfile 
  40.    guiopen filereq.gc $gui $routine $path $favfile
  41.  
  42.  
  43. XONOPEN  gui routine path favfile 
  44.    setgad filereq.gc 52/53 off
  45.    if $path > ''
  46.       lvuse filereq.gc 1
  47.       LVDir '#$path'
  48.       update filereq.gc 2 $$lv.dir      
  49.    endif
  50.    if $favfile = ""
  51.       favfile = guis:tools/fav/default
  52.    endif
  53.    
  54.  
  55. xOnRMB
  56.    if $mode = FAV
  57.       setgad filereq.gc 52/53 off
  58.       setgad filereq.gc 2/16 on
  59.       setgad filereq.gc 50/51 on
  60.       lvuse filereq.gc 1
  61.       lvmode DIR
  62.       lvdir #$$lv.dir
  63.       mode = ''
  64.    else
  65.       guiopen FileReq2    ; open the pop-up gui (end of this file)
  66.    endif
  67.  
  68. xOnQuit
  69.     guiquit FileReq2
  70.  
  71.  
  72. ; ====================================================================
  73.  
  74. ;               The Listview
  75.  
  76. ; ====================================================================
  77.  
  78. XLISTVIEW 9 5 213 190 "" filename "" 10 DIR
  79.    GADID 1
  80.    GADFONT #mono 8 000
  81.    if $mode = FAV
  82.       setgad filereq.gc 52/53 off
  83.       setgad filereq.gc 2/16 on
  84.       setgad filereq.gc 50/51 on
  85.       mode = ''
  86.       lvmode DIR
  87.       lvdir #$filename
  88.    else
  89.       guiclose filereq.gc
  90.       gosub $gui $routine $filereq.gc/filename  ; Give FULL variable path!
  91.    endif
  92.  
  93.  
  94. ; directory hook
  95. xlvdirhook 1
  96.    update filereq.gc 2 $filename       
  97.  
  98.  
  99. ; single click hook
  100. xlvhook 1
  101.    update filereq.gc 2 $filename
  102.  
  103.  
  104. XTEXTIN 9 194 273 14 "" txtfile "" 100
  105.    GADID 2
  106.    gadhelp 'Shows file chosen - Change the name & hit enter, to Rename it'
  107.    ifexists file $txtfile
  108.       guiclose filereq.gc
  109.       gosub $gui $routine $filereq.gc/filename
  110.    else
  111.       ezreq 'Rename $filename\nto $txtfile ?' Rename|CANCEL choice
  112.       if $choice = 1
  113.          rename $filename $txtfile
  114.          lvuse filereq.gc 1
  115.          lvdir refresh
  116.       endif
  117.    endif
  118.    
  119.  
  120. ; ====================================================================
  121.  
  122. ;               Listview control buttons
  123.  
  124. ; ====================================================================
  125.  
  126. XBUTTON 224 5 58 14 "Parent"
  127.    gadid 10
  128.    gadhelp 'CD to Parent of current dir'
  129.    lvuse filereq.gc 1
  130.    LVDir parent
  131.    update filereq.gc 2 $$lv.dir      
  132.    
  133.  
  134. XBUTTON 224 19 58 14 "Root"
  135.    gadid 11
  136.    gadhelp 'CD to Root of current dir'
  137.    lvuse filereq.gc 1
  138.    LVDir root
  139.    update filereq.gc 2 $$lv.dir      
  140.    
  141.  
  142. XBUTTON 224 33 58 14 "Disks"
  143.    gadid 12
  144.    gadhelp 'Show device list'
  145.    lvuse filereq.gc 1
  146.    LVDir disks
  147.    update filereq.gc 2 $$lv.dir      
  148.    
  149.  
  150. XBUTTON 224 47 58 14 "All"
  151.    gadid 13
  152.    gadhelp 'Select all items'
  153.    lvuse filereq.gc 1
  154.    LVDir all
  155.    update filereq.gc 2 $$lv.dir      
  156.    
  157.  
  158. XBUTTON 224 61 58 14 "None"
  159.    gadid 14
  160.    gadhelp 'Unselect all items'
  161.    lvuse filereq.gc 1
  162.    LVDir none
  163.    update filereq.gc 2 $$lv.dir      
  164.    
  165. ; ====================================================================
  166.  
  167. ;               Copy & delete
  168.  
  169. ; ====================================================================
  170.  
  171. XBUTTON 224 92 58 14 ""
  172.    gadid 14
  173.    
  174. XBUTTON 224 78 58 14 ""
  175.    gadid 14
  176.  
  177. XBUTTON 224 106 58 14 "MkDir"
  178.    gadid 16
  179.    gadhelp 'Create directory named $txtfile'
  180.    guiclose filereq.gc
  181.    ifexists dir $txtfile
  182.    orifexists file $txtfile
  183.       ezreq 'ERROR: Invalid directory name.\n\nEnter valid name for directory\nin the TxtIn gadget and try again..' OK ''
  184.    else
  185.       makedir $txtfile
  186.       lvdir #$txtfile
  187.       update filereq.gc 2 $filename       
  188.    endif
  189.    
  190.  
  191. ; ====================================================================
  192.  
  193. ;               Favourites control
  194.  
  195. ; ====================================================================
  196.  
  197. XBUTTON 224 123 58 14 "Fav"
  198.    gadid 50
  199.    gadhelp 'Shows Favourites listing ($favfile\)'
  200.    setgad filereq.gc 2/16 off
  201.    setgad filereq.gc 50/51 off
  202.    setgad filereq.gc 52/53 on
  203.    lvuse filereq.gc 1
  204.    lvmode MULTI
  205.    lvchange $favfile
  206.    lvsort asc
  207.    mode = FAV
  208.    
  209.  
  210. XBUTTON 224 137 29 14 "+"       ; add to favourites
  211.    gadid 51                        ; create file if it doesn't exist
  212.    gadhelp 'Add current dir to Favourites'
  213.    ifexists file $favfile
  214.       ; ok
  215.    else
  216.       .dummy = 'GUIs:'             ; got to have this one :)
  217.       copy env:.dummy $favfile
  218.    endif
  219.    lvuse filereq.gc 1
  220.    append $favfile '\n$$lv.dir'
  221.    
  222.  
  223. XBUTTON 253 137 29 14 "-"     ; delete from favourites
  224.    gadid 52
  225.    gadhelp 'Deleted selected favourites entries'
  226.    lvuse filereq.gc 1
  227.    lvmulti first
  228.    while $filename > ''
  229.        lvdel -1
  230.        lvmulti first      ; since we deleted the old 1st one
  231.    endwhile
  232.    
  233.  
  234. XBUTTON 224 151 58 14 "Save"  ; save favourites
  235.    gadid 53
  236.    gadhelp 'Save Favourites as $favfile'
  237.    lvuse filereq.gc 1
  238.    lvsave $favfile
  239.    
  240. ; ====================================================================
  241.  
  242. ;               OK & Cancel
  243.  
  244. ; ====================================================================
  245.  
  246. XBUTTON 224 168 58 25 "OK"
  247.    gadid 15
  248.    gadhelp 'Selected files will be sent to calling gui'
  249.    guiclose filereq.gc
  250.    lvuse filereq.gc 1
  251.    lvmulti first
  252.    while $filename > ''
  253.       gosub $gui $routine $filereq.gc/filename
  254.       lvmulti off
  255.       lvmulti next
  256.    endwhile
  257.    
  258. ; XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
  259. ; ====================================================================
  260. ; XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
  261.  
  262. ;                          Pop - up gui
  263.  
  264. ; XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
  265. ; ====================================================================
  266. ; XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
  267.  
  268. NewFile FileReq2
  269.  
  270. WinBig 0 0 80 105 ""
  271. WinType 00001000
  272. winonmouse 30 10 
  273.  
  274. xOnRMB 
  275.     guiclose #this
  276.  
  277. xOnInactive
  278.     guiclose #this
  279.  
  280. xBefore
  281.     guiclose #this
  282.  
  283. ; -------------------- buttons 
  284.  
  285. xbutton 0  0 80 15 "Search"
  286.     gadhelp 'Load the Search.gc gui'
  287.  
  288.     lvuse filereq.gc 1
  289.     path = $$lv.dir
  290.     if $path < ' '
  291.        path = sys:
  292.     endif
  293.     guiload guis:g4c/fsearch/fsearch.gc $filereq2/path
  294.  
  295. xbutton 0 15 80 15 'Copy'
  296.    gadhelp 'Copy selected files (destination chosen through requester)'
  297.    dest = ''
  298.    ReqFile -1 -1 300 -40 'Choose destination:' DIR dest ''
  299.    if $dest > ' '
  300.       lvuse filereq.gc 1
  301.       lvaction copy $dest
  302.    endif
  303.  
  304. xbutton 0 30 80 15 'Delete'
  305.    gadhelp 'Delete selected files'
  306.    lvuse filereq.gc 1
  307.    lvaction delete REQ
  308.  
  309. xbutton 0 45 80 15 ''
  310.  
  311. xbutton 0 60 80 15 ''
  312.  
  313. xbutton 0 75 80 15 ''
  314.  
  315. xbutton 0 90 80 15 ''
  316.  
  317.  
  318.  
  319.  
  320.  
  321.  
  322.